<?php

if(isset($_POST['changeproduct'])){
    $userid = $_POST['useridtilgang'];
    $email = $_POST['email'];
    $productname = $_POST['productname'];
    echo $productname;
    $productid = $_POST['productid'];
   $message = $CP_controller->grantAccessP($userid,$email,$productname,$productid);
    
    
}
$companyid = 0;
if(isset($_POST['changecompany'])){
    $userid = $_POST['useridtilgang'];
    $email = $_POST['email'];
    $companyname = $_POST['companyname'];
    $companyid = $_POST['companyid'];
    echo $companyid;
    echo $companyname;
    $message = $CP_controller->grantAccessC($userid,$email,$companyname,$companyid);

}

if($message != "" && !empty($message)){
    
    echo "<div id='error'>".$message."</div>";
}
?>
<div id="admedit">
    <h2>Gi tilgang</h2>
    <fieldset>
        <legend> <h3> Gi produkttilgang</h3> </legend>
<form method="post" id="adminchangep">
    <label > User ID</label> <em></em><input name="useridtilgang" value="<?php echo $_SESSION['user_id']; ?>">Eller</br>
    <label > Email</label> <em></em><input name="email" value=""></br></br>
    <label > ProduktNavn</label> <em></em><input name="productname">Eller  </br>
    <label > Produkt ID</label> <em></em><input name="productid" value=""></br>
    
    <input type="submit" name="changeproduct" value="Gi tilgang på Produktendring" >
    </fieldset>
    
    <fieldset>
        <legend><h3> Gi bedriftstilgang </h3></legend>
</form>
<form method="post" id="adminchangec">
    <label > User ID</label> <em></em><input name="useridtilgang" value="<?php echo $_SESSION['user_id']; ?>">Eller</br>
    <label > Email</label> <em></em><input name="email" value=""></br></br>
    <label > Bedriftnavn</label> <em></em><input name="companyname"> Eller </br>
    <label > Bedriftsid ID</label> <em></em><input name="companyid" value=""></br>
    <input type="submit" name="changecompany" value="Gi tilgang på Bedriftsendring" >
    </fieldset>
</form>
    
</div>